<?php

use App\Http\Controllers\CaptchaController;
use App\Http\Controllers\CashbookController;
use App\Http\Controllers\CashflowController;
use App\Http\Controllers\CategoryController;
use App\Http\Controllers\loginController;
use App\Http\Controllers\MemberController;
use App\Http\Controllers\StatisticController;
use Illuminate\Support\Facades\Route;

Route::post('code2token', [loginController::class, 'code2token']);
Route::post('v2/code2token', [loginController::class, 'code2tokenV2']);

Route::get('captcha', [CaptchaController::class, 'getCaptchaApi']);
Route::post('login', [loginController::class, 'login']);
Route::post('register', [loginController::class, 'register']);

Route::middleware(['auth:member'])->group(function () {
    Route::get('me',  [MemberController::class, 'me']);
    Route::put('profile',  [MemberController::class, 'updateProfile']);

    Route::get('category', [CategoryController::class, 'appIndex']);
    Route::delete('category/{id}', [CategoryController::class, 'appDel']);
    Route::put('category', [CategoryController::class, 'appUpdate']);
    Route::post('category', [CategoryController::class, 'appStore']);

    Route::post('cash-flow', [CashflowController::class, 'appStore']); // TODO 待移除
    Route::post('cashflow', [CashflowController::class, 'appStore']);
    Route::get('cashflow-list', [CashflowController::class, 'appList']);
    Route::get('cashbook', [CashbookController::class, 'appIndex']);
    Route::get('cashflow/{id}', [CashflowController::class, 'appShow']);
    Route::put('cashflow', [CashflowController::class, 'appUpdate']);
    Route::delete('cashflow/{id}', [CashflowController::class, 'appDestroy']);
    Route::get('notifications', [MemberController::class, 'notifications']);
    Route::get('notification/{id}', [MemberController::class, 'notification']);
    Route::put('notification/{id}', [MemberController::class, 'readNotification']);
    Route::delete('notification/{id}', [MemberController::class, 'delNotification']);

    // 统计
    Route::get('statistic/type', [StatisticController::class, 'statisticByType']);
});
